package com.example.demo.controller;

import com.example.demo.mapper.areaMapper;
import com.example.demo.mapper.bookMapper;
import com.example.demo.mapper.teacherService;
import com.example.demo.model.area;
import com.example.demo.model.book;
import com.example.demo.model.teacher;
import com.example.demo.model.tip;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;


@Controller
@EnableAutoConfiguration

public class Example<list> {

    @Resource
    private teacherService tt;

    @Resource
    private bookMapper mm;

    @Resource
    private areaMapper aa;

    @ResponseBody
    @RequestMapping(value = "/", method = RequestMethod.GET)
    String a() {
        return "<h3>HelloWorld</h3>";
    }

    @RequestMapping(value = "/abc", method = RequestMethod.GET)
    String getabc() {
        return "abc";
    }

    @ResponseBody
    @RequestMapping(value = "/tip", method = RequestMethod.GET)
    tip gettip(@RequestParam("name") String name, @RequestParam("age") Integer age) {
        return new tip(name + age);
    }

    @RequestMapping(value = "/t", method = RequestMethod.GET)
    String gett() {
        return "shope";
    }

    @ResponseBody
    @RequestMapping(value = "/findall", method = RequestMethod.GET)
    ArrayList<teacher> findall() {
        return tt.findAll();
    }

    @ResponseBody
    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
    ArrayList<book> findAll() {
        return mm.findAll();
    }

    @ResponseBody
    @RequestMapping(value = "/findByDeep",method = RequestMethod.GET)
    ArrayList<area> findByDeep(int deep,int pid){
            return aa.findByDeep(deep,pid);
    }

    @RequestMapping(value = "/three",method = RequestMethod.GET)
    String fi(){
        return "three";
    }
}
